﻿using System.Windows.Forms;
using System.IO;
namespace MotivLogger
{
    public class MainLog : ILogMethod
    {
        private ISetting LoggerSettings;
        private string path;
        public MainLog()
        {
            ;
            LoggerSettings = Settings.getSetting("logger");
            string path = this.LoggerSettings.GetStr("logpath", "logs");
                if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            string file = this.LoggerSettings.child["logmethods"].child["mainlog"].GetStr("file", "all.log");
            path = Path.Combine(path, file);
        }

        public void Log(MotivLogger.LogLevels Level, string Message, string Actor)
        {
            string path = this.LoggerSettings.GetStr("logpath", "logs2");
            string file = this.LoggerSettings.child["logmethods"].child["mainlog"].GetStr("file", "all.log");
            path = Path.Combine(path, file);
            string message = LoggerBase.BuildLogRecord(Level, Message, Actor);
            StreamWriter w = new StreamWriter(path, true);
            w.WriteLine(message);
            w.Close();
        }

        public void Stop() { ;}

    }
}
